package demo;

class MyCircularQueue {
    public int[] elem;
    public int usedsize;
    public MyCircularQueue(int k) {
        elem = new int[k];
    }
    
    public boolean enQueue(int value) {
        if(isFull()) {
            return false;
        }
        elem[usedsize] = value;
        usedsize++;
        return true;
    }
    
    public boolean deQueue() {
        if(isEmpty()) {
            return false;
        }
        usedsize--;
        return true;
    }
    
    public int Front() {
        if(isEmpty()) {
            return -1;
        }
        return elem[0];
    }
    
    public int Rear() {
        if(isEmpty()) {
            return -1;
        }
        return elem[usedsize--];
    }
    
    public boolean isEmpty() {
        return usedsize == 0;
    }
    
    public boolean isFull() {
        return usedsize == elem.length;
    }
}